let actionCreator = (type, payload) => ({ type, payload });
export const SET_PRODUCT = function(parm) {
  return function(dispatch) {
    fetch("http://106.12.79.128:666/personalized")
      .then(body => body.json())
      .then(res => {
        dispatch(actionCreator("SET_PRODUCT", res.result));
      })
      .catch(err => {
        throw new Error(err);
      });
  };
};
export const GETMAINPIC = function(parm) {
  return function(dispatch) {
    fetch("http://106.12.79.128:666/banner")
      .then(body => body.json())
      .then(res => {
        dispatch(actionCreator("GETMAINPIC", res.banners));
      })
      .catch(err => {
        throw new Error(err);
      });
  };
};
export const SET_RADIO = function(parm) {
  return function(dispatch) {
    fetch("http://106.12.79.128:666/dj/paygift?limit=10&offset=20")
      .then(body => body.json())
      .then(res => {
        dispatch(actionCreator("SET_RADIO", res.data.list));
      })
      .catch(err => {
        throw new Error(err);
      });
  };
};
